import http from '@/api'
import { ADMIN_MODULE } from '@/api/helper/prefix'
import type { IDict } from '@/api/interface/system/dict'
import type { IPage } from '@/api/interface'

/**
 * 字典类别列表
 * @param params
 * @returns {*}
 */
export const getDictType = (params: IDict.DictTypeQuery) => {
  return http.post<IPage<IDict.DictType>>(ADMIN_MODULE + `/sys-dictType/list`, params)
}

/**
 * 添加字典类别
 * @param params
 * @returns {*}
 */
export const addDictType = (params: IDict.DictType) => {
  return http.post(ADMIN_MODULE + `/sys-dictType/add`, params)
}

/**
 * 修改字典类型
 * @param params
 * @returns {*}
 */
export const editDictType = (params: IDict.DictType) => {
  return http.post(ADMIN_MODULE + `/sys-dictType/update`, params)
}

/**
 * 删除字典类型
 * @param params
 * @returns {*}
 */
export const deleteDictType = (params: { ids: string[] }) => {
  return http.post(ADMIN_MODULE + `/sys-dictType/remove`, params)
}

/**
 * 锁定字典类型
 * @param params
 * @returns {*}
 */
export const lockDictType = (params: { ids: string[] }) => {
  return http.post(ADMIN_MODULE + `/sys-dictType/lock`, params)
}

/**
 * 获取字典数据列表
 * @param params
 * @returns {*}
 */
export const getDictData = (params: IDict.DictQuery) => {
  return http.post<IPage<IDict.Dict>>(ADMIN_MODULE + `/sys-dict/list`, params)
}

/**
 * 添加字典类别
 * @param params
 * @returns {*}
 */
export const addDictData = (params: IDict.Dict) => {
  return http.post(ADMIN_MODULE + `/sys-dict/add`, params)
}

/**
 * 修改字典
 * @param params
 * @returns {*}
 */
export const editDictData = (params: IDict.Dict) => {
  return http.post(ADMIN_MODULE + `/sys-dict/update`, params)
}

/**
 * 锁定字典
 * @param params
 * @returns {*}
 */
export const lockDictData = (params: IDict.Dict) => {
  return http.post(ADMIN_MODULE + `/sys-dict/lock`, params)
}

/**
 * 删除字典
 * @param params
 * @returns {*}
 */
export const deleteDictData = (params: { ids: string[] }) => {
  return http.post(ADMIN_MODULE + `/sys-dict/delete`, params)
}

/**
 * 获取所有字典信息
 * @returns {*}
 */
export const getAllDict = () => {
  return http.get<Record<string, IDict.DictCustom[]>>(
    ADMIN_MODULE + `/sys-dict/all`,
    {},
    { loading: false }
  )
}


//字典类型选项
export const getDictTypeOptions = () => {
  return http.get<IDict.DictType[]>(ADMIN_MODULE + `/sys-dictType/selectOptionsType`)
}
